package com.diandian.backend.dingding.data.controller;

import com.diandian.backend.dingding.data.service.DingdingStaffExtendService;
import com.diandian.base.boot.starter.response.BaseResult;
import com.diandian.base.boot.starter.util.ResultUtil;
import com.diandian.backend.dingding.data.param.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * [钉钉]员工扩展信息表
 *
 * @author zyz diandian@qq.com
 * @since 1.0.0 2025-11-07
 */
@RestController
@RequestMapping("/staff/extend")
public class DingdingStaffExtendController {

    @Autowired
    private DingdingStaffExtendService iDingdingStaffExtendService;

    /**
     * 查询详情
     */
    @PostMapping("/detail")
    public BaseResult getDetail(@RequestBody DingdingStaffExtendDetailParam param) {
        param.check();
        return ResultUtil.makeResult(iDingdingStaffExtendService.getDetail(param.toDTO()));
    }

    /**
     * 有则更新，无则新增
     */
    @PostMapping("/sync")
    public BaseResult sync(@RequestBody DingdingStaffExtendSyncParam param) {
        param.check();
        iDingdingStaffExtendService.sync(param.toDTO());
        return ResultUtil.makeResult();
    }




    /**
     * 根据数据id更新数据
     */
    @PostMapping("/updateById")
    public BaseResult updateById(@RequestBody DingdingStaffExtendUpdateByIdParam param) {
        param.check();
        iDingdingStaffExtendService.updateById(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 分页查询
     */
    @PostMapping("/page")
    public BaseResult page(@RequestBody DingdingStaffExtendPageParam param) {
        param.check();
        return ResultUtil.makeResult(iDingdingStaffExtendService.page(param.toDTO()));
    }

    /**
     * 根据数据id删除数据
     */
    @PostMapping("/deleteById")
    public BaseResult deleteById(@RequestBody DingdingStaffExtendDeleteByIdParam param) {
        param.check();
        iDingdingStaffExtendService.deleteById(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 新增
     */
    @PostMapping("/add")
    public BaseResult add(@RequestBody DingdingStaffExtendAddParam param) {
        iDingdingStaffExtendService.add(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 列表查询
     */
    @PostMapping("/list")
    public BaseResult list(@RequestBody DingdingStaffExtendListParam param) {
        return ResultUtil.makeResult(iDingdingStaffExtendService.getList(param.toDTO()));
    }

}